<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // function sum(a, b, cb) {
        //     setTimeout(() => {
        //         cb(a + b)
        //     }, 10000)
        // }

        // sum(123, 456, result => {
        //     sum(result, 777, result => {
        //         console.log(result)
        //     })
        // })

        // function sum(a, b) {
        //      setTimeout(() => {
        //         return a+b
        //     }, 2000)
        // }

        // // console.log("第一行打印")
        // var result = sum(123, 456)
        // console.log(result)

        // setTimeout(() => {
        //     console.log( sum(123, 456));
        // }, 3000)

        // console.log("第二行打印")


        function sum(a, b, cb) {
            setTimeout(() => {
                cb(a + b)
            }, 2000)
        }

        
        function fn1(result) {
            console.log(result)
        }




        console.log("第一行打印")
        sum(123, 456, result => {
            console.log(result)
        })
        console.log("第二行打印")



        function sum(a, b, fn1) {
            setTimeout(() => {
                fn1(a + b)
            }, 2000)
        }
    </script>
</body>

</html>